package com.bsoft.gol.hbs.bbpmessagel.enums;

/**
 * @Describe: 消息推送方式枚举
 * @Author: zhengcb10708
 * @Date: 2022/3/13 9:27
 */
public enum MsgTypeEnum {

    APP_NEWS_PAGE("app待办事项", new Byte("1")),
    OFFLINE_SERVICE("app消息页", new Byte("2")),
    APP_PUSH_AURORA("app推送（极光）", new Byte("3")),
    WECHAT_OFFICIAL_ACCOUNT_TEMP_MSG("微信公众号模板消息", new Byte("4")),
    WECHAT_APPLETS_SUBSCRIBE_MSG("微信小程序订阅消息", new Byte("5")),
    MOBILE_PHONE_SHORT_MSG("手机短信", new Byte("6"));
    private Byte code;
    private String text;

    MsgTypeEnum(String text, Byte code) {
        this.code = code;
        this.text = text;
    }

    public Byte getCode() {
        return this.code;
    }

    public String getText() {
        return this.text;
    }

    public static MsgTypeEnum get(Byte code) {
        for (MsgTypeEnum msgTypeEnum : values()) {
            if (msgTypeEnum.getCode().equals(code)) {
                return msgTypeEnum;
            }
        }
        return null;
    }

    public static String getText(Byte code) {
        MsgTypeEnum msgTypeEnum = get(code);
        return msgTypeEnum == null ? "" : msgTypeEnum.getText();
    }

    public static int getCode(String text) {
        for (MsgTypeEnum msgTypeEnum : values()) {
            if (msgTypeEnum.getText().equals(text)) {
                return msgTypeEnum.getCode();
            }
        }
        return 0;
    }
}
